<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <style>
      .aa{
          border: 3px solid pink;
          box-shadow: 1px 3px 4px gray;
      }
    </style>
</head>
<body>
    <p id="p1">天气不错</p>

    

    <script>
        let p1 = document.getElementById("p1");
        p1.style.color = "red";
        p1.style.backgroundColor = "yellow";
        p1.style.fontSize = "30px";
        p1.style.fontFamily = "楷体";

        //附上class属性 后面可以接已写好的值。
        p1.className  = 'aa';


        //获取样式(只能行内样式)
        alert(p1.style.color)

        //终极获取样式
        alert(document.defaultView.getComputedStyle(p1,null).border)
    </script>
</body>
</html>